#import "XMRCDataSource.h"


@implementation XMRCDataSource
+ (XMRCDataSource *)sharedInstance {
    static XMRCDataSource *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [[self alloc] init];
    });
    return sharedInstance;
}
#pragma mark - RCIMUserInfoDataSource
- (void)getUserInfoWithUserId:(NSString *)userId completion:(void (^)(RCUserInfo *))completion {
    XMLog(@"getUserInfoWithUserId ----- %@", userId);
    if ([userId isEqualToString:@"__group_apply__"]) {
        return;
    }
    if (userId.length > 0) {
        NSMutableDictionary *dic = @{
            @"see_user_id":userId,
            @"module": @"7"
        }.mutableCopy;
        [YHNetworkManager.sharedInstance postWithUrl:@"api/user/obtain" parameters:dic completeBlock:^(XMResponseTip * _Nonnull tip, id  _Nullable result) {
            if (tip.success) {
                XMUserModel *model = [XMUserModel mj_objectWithKeyValues:result];
                RCUserInfo *user = [[RCUserInfo alloc] initWithUserId:model.user_id name:model.nickname portrait:model.avatar.file_url];
                user.alias = [NSString xm_stringNoNullWith:model.alias];
                user.extra = [XMUtil extraJsonMember_time:[NSString xm_stringNoNullWith:model.member_time] intimacy:[NSString xm_stringNoNullWith:kValueToString(model.intimacy)]];
                completion(user);
            }
        }];
    }
    return;
}

@end
